package flex.cc.single.controller;

import com.alibaba.fastjson.JSONObject;
import flex.cc.core.support.BaseController;
import flex.cc.single.service.AppointmentService;
import flex.cc.wrapper.WrapMapper;
import flex.cc.wrapper.Wrapper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author wkangle
 * @className SingleDrivingController
 * @description 单项到店Controller
 * @time 2022-04-06 22:05:57
 */
@SuppressWarnings("restriction")
@RestController
@RequestMapping(value = "/vehicleSvr/singleService/wechat")
public class SingleStoreController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(SingleStoreController.class);


    @Autowired
    private AppointmentService appointmentService;

    @PostMapping(value = "/saveBooking")
    @ApiOperation(httpMethod = "POST", value = "预约提交")
    public Wrapper<JSONObject> saveBooking(@ApiParam(name = "reqVo", value = "请求信息") @RequestBody Map<String, Object> reqVo) {
        logger.info("SingleStoreController -- saveBooking() ====> {}", reqVo);
        JSONObject storeAppointment = appointmentService.createStoreAppointment(reqVo);
        return WrapMapper.ok(storeAppointment);
    }

    @PostMapping(value = "/queryBookingInfo")
    @ApiOperation(httpMethod = "POST", value = "单项到店类卡券预约信息")
    public Wrapper<Map<String, Object>> queryBookingInfo(@ApiParam(name = "reqVo", value = "请求信息") @RequestBody Map<String, Object> reqVo) {
        logger.info("SingleStoreController -- queryBookingInfo() ====> {}", reqVo);
        Map<String, Object>  bookingInfo = appointmentService.queryBookingInfo(reqVo);
        return WrapMapper.ok(bookingInfo);
    }

    @PostMapping(value = "/querySearchAddress")
    @ApiOperation(httpMethod = "POST", value = "根据用户输入的地址查询对应的坐标，用于搜索门店列表")
    public Wrapper<Map<String, Object>> querySearchAddress(@ApiParam(name = "reqVo", value = "请求信息") @RequestBody Map<String, Object> reqVo) {
        logger.info("SingleStoreController -- querySearchAddress() ====> {}", reqVo);
        Map<String, Object> querySearchAddress = appointmentService.querySearchAddress(reqVo);
        return WrapMapper.ok(querySearchAddress);
    }

}
